package com.common.frame.widget

import android.text.TextPaint
import android.text.style.ClickableSpan
import android.view.View
import androidx.annotation.ColorInt
import com.common.frame.extension.getColor

class ClickableSpan(
    private val color: Int? = null,
    private val isUnderLineText: Boolean = false,
    private val onclick: (View) -> Unit
) : ClickableSpan() {
    override fun onClick(widget: View) {
        onclick(widget)
    }

    override fun updateDrawState(ds: TextPaint) {
        color?.let {
            ds.color = it.getColor()
        }
        ds.isUnderlineText = isUnderLineText
    }
}